TARGET = led

OBJECTS = start.o led.o

CPU = -mcpu=cortex-m3
MCU = $(CPU) -mthumb

CFLAGS = $(MCU) -Wall

all : $(TARGET).elf $(TARGET).hex $(TARGET).bin $(TARGET).dis
	arm-none-eabi-size $<

%.o: %.c
	arm-none-eabi-gcc -c $(CFLAGS)  $< -o $@

%.o: %.s
	arm-none-eabi-gcc -c $(CFLAGS)  $< -o $@

$(TARGET).elf: $(OBJECTS)
	arm-none-eabi-ld  $(OBJECTS) -Ttext 0X8000000 -o $@

%.hex: %.elf 
	arm-none-eabi-objcopy -O ihex $< $@

%.bin: %.elf
	arm-none-eabi-objcopy -O binary -S $< $@

%.dis: %.elf
	arm-none-eabi-objdump -D -m cortex-m3 $< > $@

clean:
	rm -rf *.o led.elf led.hex led.bin led.dis
